package com.lifl.b328.garden.model;

import android.content.Context;
import android.database.Cursor;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CursorAdapter;
import android.widget.TextView;

public class CursorNoteAdapter extends CursorAdapter {
	
	protected final LayoutInflater inflater;
	
	public CursorNoteAdapter(Context context, Cursor c, boolean autoQuery) {
		super(context, c, autoQuery);
		inflater = LayoutInflater.from(context);
	}
	
	public CursorNoteAdapter(Context context, Cursor c){
		super(context,c);
		inflater = LayoutInflater.from(context);
	}

	@Override
	public void bindView(View view, Context context, Cursor cursor) {
		TextView tv1 = (TextView) view.findViewById(android.R.id.text1);
		TextView tv2 = (TextView) view.findViewById(android.R.id.text2);
	
		String s1 = cursor.getString(cursor.getColumnIndex(Constantes.KEY_VIEW_NOTEUSER_CONTENT))+
				" "+cursor.getString(cursor.getColumnIndex(Constantes.KEY_VIEW_NOTEUSER_LONGITUDE));
		String s2 = cursor.getString(cursor.getColumnIndex(Constantes.KEY_VIEW_NOTEUSER_EDITION));
		
		tv1.setText(s1);
		tv2.setText(s2);
	}

	@Override
	public View newView(Context context, Cursor cursor, ViewGroup parent) {
		final View view = inflater.inflate(android.R.layout.two_line_list_item, parent, false);
		return view;
	}

}
